﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.world.machines {
    import flash.events.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.world.vos.actors.machines.*;
    import net.wooga.pets.constants.*;

    public class FountainMachineMediator extends AbstractMachineMediator {

        override public function onRegister():void{
            super.onRegister();
            addContextListener(EventConstants.SET_FOUNTAIN_STATE, this.onSetFountainState);
            addViewListener(EventConstants.REGENERATION_FINISHED, this.onRegenerationFinished);
            dispatch(new InfoEvent(EventConstants.CLOSE_SHOP));
        }
        private function onSetFountainState(_arg1:InfoEvent):void{
            var _local2:String;
            if (_arg1.id == id){
                _local2 = _arg1.info.toString();
                this.view.setState(_local2);
                if (this.vo.patient){
                    if (_local2 == WorldConstants.WORKING){
                        this.view.setAnimation(this.vo.patient.type);
                    } else {
                        this.view.setPatient(this.vo.patient.type);
                    };
                };
            };
        }
        private function onRegenerationFinished(_arg1:Event):void{
            this.vo.state = WorldConstants.FINISHED;
        }
        private function get view():FountainMachineView{
            return ((viewComponent as FountainMachineView));
        }
        private function get vo():FountainMachineVO{
            return ((_vo as FountainMachineVO));
        }

    }
}//package net.wooga.pets.views.world.machines 
